package pres.lnk.learn.designpattern.s_memento;

/**
 * 对象，里面有个状态
 * @Author lnk
 * @Date 2018/6/5
 */
public class Originator {
    private String state;

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Memento createMemento(){
        return new Memento();
    }

    public void restoreMemento(MementoIF mementoIF){
        Memento memento = (Memento)mementoIF;
        this.state = memento.state;
    }

    public class Memento implements MementoIF{
        private String state;

        public Memento() {
            this.state = Originator.this.state;
        }
    }
}
